home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cchh01.arc / MATH.H < prev    next >
C/C++ Source or Header  |  1986-03-14  |  2KB  |  99 lines

  1. /**
  2. *
  3. * Redefine secondary simulation function names to become primary names
  4. * for systems without a Numeric Data Processor.
  5. *
  6. */
  7. #ifdef NONDP
  8. #define _acos acos
  9. #define _asin asin
  10. #define _atan atan
  11. #define _cos cos
  12. #define _cosh cosh
  13. #define _cot cot
  14. #define _exp exp
  15. #define _fabs fabs
  16. #define _ldexp ldexp
  17. #define _log log
  18. #define _log10 log10
  19. #define _modf modf
  20. #define _pow pow
  21. #define _pow2 pow2
  22. #define _sin sin
  23. #define _sinh sinh
  24. #define _sqrt sqrt
  25. #define _tan tan
  26. #define _tanh tanh
  27. #endif
  28.  
  29. /**
  30. *
  31. * Structure to hold information about math exceptions
  32. *
  33. */
  34. struct exception 
  35.     {
  36.     int type;        /* error type */
  37.     char *name;        /* math function name */
  38.     double arg1, arg2;     /* function arguments */
  39.     double retval;        /* proposed return value */
  40.     };
  41.  
  42. /*
  43. *
  44. * Exception type codes, found in exception.type
  45. *
  46. */
  47. #define DOMAIN    1    /* domain error */
  48. #define SING      2    /* singularity */
  49. #define OVERFLOW  3    /* overflow */
  50. #define UNDERFLOW 4    /* underflow */
  51. #define TLOSS      5    /* total loss of significance */
  52. #define PLOSS      6    /* partial loss of significance */
  53.  
  54. /**
  55. *
  56. * Error codes generated by basic arithmetic operations (+ - * /)
  57. *
  58. */
  59. #define FPEUND 1    /* underflow */
  60. #define FPEOVF 2    /* overflow */
  61. #define FPEZDV 3    /* zero divisor */
  62. #define FPENAN 4    /* not a number (invalid operation) */
  63.  
  64. /**
  65. *
  66. * Constants 
  67. *
  68. */
  69. #define PI   3.14159265358979323846
  70. #define PID2 1.57079632679489661923    /* PI divided by 2 */
  71. #define PID4 0.78539816339744830962    /* PI divided by 4 */
  72. #define I_PI 0.31830988618379067154    /* Inverse of PI */
  73. #define I_PID2 0.63661977236758134308    /* Inverse of PID2 */
  74.  
  75. #define HUGE 1.797693e308        /* huge value */
  76. #define TINY 2.2e-308            /* tiny value */
  77. #define LOGHUGE 709.778            /* natural log of huge value */
  78. #define LOGTINY -708.396        /* natural log of tiny value */
  79.  
  80. /**
  81. *
  82. * External declarations
  83. *
  84. */
  85. extern int _fperr;    /* floating point arithmetic error */
  86. extern int errno;    /* UNIX error code */
  87.  
  88. extern char *ecvt();
  89. extern short *seed48();
  90. extern int atoi(),matherr();
  91. extern long atol(),strtol(),lrand48(),nrand48(),mrand48(),jrand48();
  92. extern double atof(),exp(),log(),log10(),pow(),sqrt();
  93. extern double floor(),ceil(),fmod(),fabs(),frexp(),ldexp(),modf();
  94. extern double sinh(),cosh(),tanh(),sin(),cos(),tan(),cot(),asin(),acos();
  95. extern double atan(),atan2(),except();
  96. extern double drand48(),erand48();
  97.  
  98.  
  99.